home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15098 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  47 lines

  1. Path: nntp.teleport.com!usenet
  2. From: GHouck <hksys@teleport.com>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Passing to C prog from Dos Prompt
  5. Date: 17 Apr 1996 04:51:13 GMT
  6. Organization: systems hk
  7. Message-ID: <4l1tc1$ibj@nadine.teleport.com>
  8. References: <4l0qei$gj9@soap.news.pipex.net>
  9. NNTP-Posting-Host: ip-pdx16-41.teleport.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.22 (Windows; I; 32bit)
  14.  
  15. unregistered@dial.pipex.com (ZXCV) wrote:
  16. >i apologise if this question has done the rounds before,
  17. >as I haven't got the time to check all 1500 odd articles.
  18. >
  19. >basically, I want to pass some parameters to a program from DOS
  20. >eg, for the program IDLP :
  21. >
  22. >C:\>IDLP /?
  23. >C:\>IDLP test.dlt
  24. >
  25. >This is annoying as i had the routinew for this but seem to have lost
  26. >it. ARRGH!
  27. >
  28. >ZXCV.
  29.  
  30. You should use the command-line arguments provided by the OS, i.e.:
  31.  
  32. int main( int argc, char *argv[] )
  33. {
  34.   int  i;
  35.  
  36.   for( i=1; i<argc; i++ ) {      /* argv[0] is usually the program file */
  37.  
  38.     printf( "\nArg %d = %s",i,argv[i] );
  39.   }
  40.  
  41. You are given an array of pointers to characters (*argv[]), and the number
  42. of them (argc), for all white-space-delimited command-line arguments
  43. present when the executable is invoked.
  44.  
  45. Yours, Geoff Houck
  46.  
  47.